function pop_summary_multiTime(ExpGroup)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   mean of population activity
%   For 1 layer exp use only the first 2 arguments
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tmp_data_dir = '\\KELLER-RIG1-ANA\RawData\';
adata_dir = '\\argon.fmi.ch\keller.g\AData\';
for ind=1:length(ExpGroup)
    display(['Exp: ' num2str(ExpGroup(ind))]);
    fig_pos=[2890+(330*(ind-1))        -166         319         980];
    [adata_file,mouse_id,userID]=find_adata_file(ExpGroup(ind),adata_dir);
    orig=load([adata_dir userID '\' mouse_id '\' adata_file],'ROIs','nbr_frames','aux_files');
    aux_data=[];
    try
        for ind=1:length(orig.aux_files)
            if exist([tmp_data_dir userID '\' mouse_id '\' orig.aux_files{ind}],'file');
                disp(['loading file ' orig.aux_files{ind} ' from local tmpdata directory']);
                curr_load_path=[tmp_data_dir userID '\' mouse_id '\' orig.aux_files{ind}];
            else
                disp(['loading file ' orig.aux_files{ind} ' from the network RawData directory']);
                curr_load_path=[rdata_dir userID '\' mouse_id '\' orig.aux_files{ind}];
            end
            
            tmp_data=load_lvd(curr_load_path);
            tmp_frames=get_frame_times(tmp_data(2,:));
            
            if orig.nbr_frames(ind)~=length(tmp_frames)
                if max(diff(tmp_frames))/median(diff(tmp_frames))<1.5 & length(tmp_frames)>orig.nbr_frames(ind)
                    disp('NC WARNING! Probably scanning too fast for FPGA to stop in the same frame')
                    disp(['--- ' num2str(length(tmp_frames)-orig.nbr_frames(ind)) ' frames too many ---'])
                    tmp_data(2,tmp_frames(orig.nbr_frames(ind)+1):end)=0;
                else
                    disp('CRITICAL WARNING! - aux data longer than it should be.')
                    %return
                    %tmp_data=tmp_data(:,1:tmp_frames(nbr_frames(ind)+1));
                    [~,last_bad_frame]=max(diff(tmp_frames));
                    tmp_data=tmp_data(:,ceil(mean([tmp_frames(last_bad_frame) tmp_frames(last_bad_frame+1)])):end);
                end
            end
            aux_data(:,end+1:end+length(tmp_data))=tmp_data;
        end
        
        frame_times=get_frame_times(aux_data(2,:));
        
        %         vars_to_assigin_base={vars_to_assigin_base{:}, 'aux_data', 'frame_times'};
    catch
        disp('Did not load aux data')
    end
    
    shutterOpen=find(diff(aux_data(1,:)>1)==1);
    
    % Code:
    % 1 = feedback
    % 2 = playback
    % 3 = baseline
    cur_frame_times=frame_times;
    if length(shutterOpen)>5
        order=[];
        for xnd=1:length(shutterOpen)
            if nbr_frames(xnd)==20000
                if xnd==length(shutterOpen)
                    order(xnd)=3;
                else
                    order(xnd)=1;
                end
            else
                order(xnd)=2;
            end
        end
    else
        order=[1 2 1 2 3];
    end
    a=1:length(order);
    order(max(a(order==2))+1:end)=3;
    cnt=1;
    stp=0;
    cnt2=1;
    onset=[];
    while stp==0;
        if cur_frame_times(cnt)>shutterOpen(cnt2+1)
            onset(cnt2)=cnt;
            cnt2=cnt2+1;
        end
        if length(onset)<length(shutterOpen)-1
            cnt=cnt+1;
        else
            stp=1;
        end
    end
    
    act_mat_tot={};
    %     max_act_tot=[];
    counter=0;
    for cnt=1:4
        act_mat=[];
        max_act_mat=[];
        for gnd=1:length(orig.ROIs{cnt})
            act=ftfil(orig.ROIs{cnt}(gnd).activity,18,0,10);
            act=psmooth(act);
            raw_act=act/median(act);
            max_act=max(raw_act);
            act_mat(gnd,:)=raw_act;
            %             max_act_mat(gnd)=max_act;
        end
        act_mat_tot{ind,cnt}=act_mat;
        %         max_act_tot(cnt)=max(max_act_mat);
    end
    
    %         figure;
    %         set(gcf,'position',fig_pos);
    %         xlim([0 size(act_mat_tot,2)])
    %         ylim([0 size(act_mat_tot,1)+1])
    %         imagesc(act_mat_tot)
    %         if ind==1 | ind==4
    %             for znd=1:size(act_mat_tot,1)
    %                 hold on
    %                 text(50,znd,num2str(znd),'fontsize',7,'color','w')
    %             end
    %         end
    %         axis off
    %         box off
    %         drawnow
end

figure;
set(gcf,'position',[2917         635        1872          93])
xlim([0 size(act_mat_tot,2)])
imagesc(mean(act_mat))
axis off
box off
drawnow